package Tencent;

import java.util.Scanner;

public class Main2 {

	public static void main(String[] args) {
    	Scanner sc=new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long sum = x+y;
        System.out.println(f(sum,x));;
        
    }
    public static long f(long sum,long x){
    	long temp = 0;
    	long cnt = 0;
        while(temp < sum){
        	cnt++;
        	temp += cnt;
        }
        if(temp!=sum){
        	return -1;
        }
        long res = 0;
        while(cnt>0){
        	x-=cnt;
        	res++;
        	cnt--;
        	if(x<=cnt){
        		res++;
        		return res;
        	}
        }
        return res;
    }
}
